<!doctype html>
<html >
<head>
<include file="Public:headinc" />
</head>
<body style="overflow:hidden;">
	<table width="100%" height="100%" border="0" cellpadding="0" cellspacing="0">
		<!-- header -->
		<tr>
			<td colspan="2">
				<div class="yy_header">
					<div class="yy_header_logo"><strong><a href="">后台管理</a></strong></div>
					<div class="yy_header_smallnav">
						<a href="javascript:;">欢迎 <?php echo $_G['adminUser']['username'];?></a>
						<a href="javascript:;" onclick="window.location.reload()">刷新</a>
						<a href="{:U('Index/logout')}">退出</a>
					</div>
					<div class="yy_header_mainnav" id="_menu">
<php>
foreach($menu['menu'] as $key=>$val) {
</php>
<a href="javascript:;" onclick="showSub('{$key}');setBg(this, '_menu')">{$val}</a>
<php> } </php>
					</div>
				</div>
				<div class="yy_line"></div>
			</td>
		</tr>
		<!-- left menu -->
		<tr >
			<td width="200" height="100%" valign="top" bgcolor="#dee4ed">
				<div class="yy_leftmenu" id="_sub">
					<!-- 子菜单区域 
					<ul>
						<li>
							<span class="yy_leftmenu_title" >{title}</span>
							<ul class="yy_leftmenu_item" >
								<li><a href="javascript:void(0)" class="active">基本信息</a></li>
								<li><a href="javascript:void(0)">统计</a></li>
								<li><a href="javascript:void(0)">设置</a></li>
							</ul>
						</li>
					</ul>
					-->
				</div>
			</td>
			<td valign="top">
				<iframe id="mainF" name="mainF" src="{:U('Main/main')}" width="100%" frameborder="0" style="min-height:300px;"></iframe>
				<script>
				(function(){
					var mainFrame = document.getElementById('mainF');
					var win = jQuery(window);
					mainFrame.style.height = win.height() - 80 + 'px';
					jQuery(window).resize(function(){
						mainFrame.style.height = win.height() - 80 + 'px';
					});
				})();
				</script>
			</td>
		</tr>
	</table>

<script>
// 页面加载完成 初始化菜单为第一个
(function(){
	var eles = document.getElementById('_menu').getElementsByTagName('a');
	if(eles[0]) {
		if(document.all) {
			eles[0].click();
		} else {
			var e = document.createEvent("MouseEvents");
			e.initEvent("click", true, true);
			eles[0].dispatchEvent(e);
		}
	}
})();

// 设置背景色
function setBg(obj, containerId) {
	var eles = document.getElementById(containerId).getElementsByTagName('a');
	for(var i=0, len=eles.length; i<len; i++) {
		eles[i].className = '';
	}
	
	obj.className = 'active';
}
// 得到子菜单
function showSub(m) {
	var con = document.getElementById('_sub');
	var s = '<ul>';
	
	var url = U('Main/ajax_getMenu');
	jQuery.post(url, 'm=' + m, function(r){
		//console.log(r);
		for(var i in r) {
			s += '<li><span class="yy_leftmenu_title" >'+ i +'</span>' +
				'<ul class="yy_leftmenu_item" >';
			
			for(var j in r[i]) {
				s += '<li><a href="'+ r[i][j] +'" target="mainF" onclick="setBg(this, \'_sub\')">'+ j +'</a></li>';
			}
			
			s += '</ul></li>';
		}
		
		s += '</ul>';
		
		con.innerHTML = s;
	}, 'json');
}
</script>
</body>
</html>

